Important!: ABL is no longer supported since OpenXava 5.3. Look at the migration notes for v5.3.
Automated Business Logic (ABL) with OpenXava
ABL is a library that allows you to write your business logic declaratively using annotations, this logic will be executed automatically on commit time.
ABL is included in OpenXava since v4.5. To active it you only need to add the next property to the persistence unit in your persistence.xml:
Now you can add declarative logic, for example, if you have an entity like the next one:
packageorg.openxava.test.modelimportjavax.persistence.*importorg.openxava.annotations.*
@Entityclass MiniOrder {
@Id
int number
@Column(length=40) @Required
String description
@Required
BigDecimal productPrice
@Required
int qtyOrdered
BigDecimal amount
}
You can define the calculation for the amount property writing a class with Logic sufix and ABL annotations:
packageorg.openxava.test.businesslogicimportcom.autobizlogic.abl.annotations.*class MiniOrderLogic {
@Formula("productPrice * qtyOrdered")// This is an ABL annotationspublicvoid deriveAmount(){}}
Just with this code each time that the database will be updated ABL will recalculate the amount value automatically.
Automated Business Logic (ABL) with OpenXava
ABL is a library that allows you to write your business logic declaratively using annotations, this logic will be executed automatically on commit time.ABL is included in OpenXava since v4.5. To active it you only need to add the next property to the persistence unit in your persistence.xml:
Now you can add declarative logic, for example, if you have an entity like the next one:
You can define the calculation for the amount property writing a class with Logic sufix and ABL annotations:
Just with this code each time that the database will be updated ABL will recalculate the amount value automatically.
Learn more about how to use ABL in OpenXava